home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / src / plsdef.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-30  |  5.9 KB  |  354 lines

  1. /* $Id: plsdef.c,v 1.10 1994/06/30 18:22:14 mjl Exp $
  2.  * $Log: plsdef.c,v $
  3.  * Revision 1.10  1994/06/30  18:22:14  mjl
  4.  * All core source files: made another pass to eliminate warnings when using
  5.  * gcc -Wall.  Lots of cleaning up: got rid of includes of math.h or string.h
  6.  * (now included by plplot.h), and other minor changes.  Now each file has
  7.  * global access to the plstream pointer via extern; many accessor functions
  8.  * eliminated as a result.
  9.  *
  10.  * Revision 1.9  1994/03/23  08:24:33  mjl
  11.  * Added support for hardware fill patterns (negative).
  12.  *
  13.  * All external API source files: replaced call to plexit() on simple
  14.  * (recoverable) errors with simply printing the error message (via
  15.  * plabort()) and returning.  Should help avoid loss of computer time in some
  16.  * critical circumstances (during a long batch run, for example).
  17. */
  18.  
  19. /*    plsdef.c
  20.  
  21.     Routines to set various plplot parameters, such as char height,
  22.     symbol size, tick length, line and fill patterns, etc.
  23. */
  24.  
  25. #include "plplotP.h"
  26.  
  27. /* Line pattern defaults */
  28.  
  29. static struct line {
  30.     PLINT nels;
  31.     PLINT mark[4];
  32.     PLINT space[4];
  33. } line[] = {
  34.  
  35.     {
  36.     0,            /* Continuous line */
  37.     {
  38.         0, 0, 0, 0
  39.     },
  40.     {
  41.         0, 0, 0, 0
  42.     }
  43.     },
  44.     {
  45.     1,
  46.     {
  47.         1000, 0, 0, 0
  48.     },
  49.     {
  50.         1000, 0, 0, 0
  51.     }
  52.     },
  53.     {
  54.     1,
  55.     {
  56.         2000, 0, 0, 0
  57.     },
  58.     {
  59.         2000, 0, 0, 0
  60.     }
  61.     },
  62.     {
  63.     1,
  64.     {
  65.         2000, 0, 0, 0
  66.     },
  67.     {
  68.         1000, 0, 0, 0
  69.     }
  70.     },
  71.     {
  72.     2,
  73.     {
  74.         2500, 1000, 0, 0
  75.     },
  76.     {
  77.         1000, 1000, 0, 0
  78.     }
  79.     },
  80.     {
  81.     2,
  82.     {
  83.         2000, 1000, 0, 0
  84.     },
  85.     {
  86.         2000, 1000, 0, 0
  87.     }
  88.     },
  89.     {
  90.     3,
  91.     {
  92.         1000, 1500, 2000, 0
  93.     },
  94.     {
  95.         1000, 1500, 2000, 0
  96.     }
  97.     },
  98.     {
  99.     3,
  100.     {
  101.         1000, 1500, 2000, 0
  102.     },
  103.     {
  104.         1000, 1000, 1000, 0
  105.     }
  106.     }
  107. };
  108.  
  109. /* Fill pattern defaults */
  110.  
  111. static struct pattern {
  112.     PLINT nlines;        /* Number of lines in pattern (1 or 2) */
  113.     PLINT inc[2];        /* Inclination 10 ths of degrees */
  114.     PLINT del[2];        /* Spacing for each line */
  115. } pattern[] = {
  116.  
  117.     {
  118.     1,
  119.     {
  120.         0, 0
  121.     },
  122.     {
  123.         2000, 0
  124.     }
  125.     },
  126.     {
  127.     1,
  128.     {
  129.         900, 0
  130.     },
  131.     {
  132.         2000, 0
  133.     }
  134.     },
  135.     {
  136.     1,
  137.     {
  138.         450, 0
  139.     },
  140.     {
  141.         2000, 0
  142.     }
  143.     },
  144.     {
  145.     1,
  146.     {
  147.         -450, 0
  148.     },
  149.     {
  150.         2000, 0
  151.     }
  152.     },
  153.     {
  154.     1,
  155.     {
  156.         300, 0
  157.     },
  158.     {
  159.         2000, 0
  160.     }
  161.     },
  162.     {
  163.     1,
  164.     {
  165.         -300, 0
  166.     },
  167.     {
  168.         2000, 0
  169.     }
  170.     },
  171.     {
  172.     2,
  173.     {
  174.         0, 900
  175.     },
  176.     {
  177.         2000, 2000
  178.     }
  179.     },
  180.     {
  181.     2,
  182.     {
  183.         450, -450
  184.     },
  185.     {
  186.         2000, 2000
  187.     }
  188.     }
  189. };
  190.  
  191. /* Set defining parameters for pattern fill */
  192.  
  193. static void
  194. spat(PLINT inc[], PLINT del[], PLINT nlin);
  195.  
  196. /*----------------------------------------------------------------------*\
  197.  * void plschr()
  198.  *
  199.  * Set character height.
  200. \*----------------------------------------------------------------------*/
  201.  
  202. void
  203. c_plschr(PLFLT def, PLFLT scale)
  204. {
  205.     if (def != 0.0) 
  206.     plsc->chrdef = def;
  207.  
  208.     plsc->chrht = scale * plsc->chrdef;
  209. }
  210.  
  211. /*----------------------------------------------------------------------*\
  212.  * void plsmin()
  213.  *
  214.  * Set up lengths of minor tick marks.
  215. \*----------------------------------------------------------------------*/
  216.  
  217. void
  218. c_plsmin(PLFLT def, PLFLT scale)
  219. {
  220.     if (def != 0.0) 
  221.     plsc->mindef = def;
  222.  
  223.     plsc->minht = scale * plsc->mindef;
  224. }
  225.  
  226. /*----------------------------------------------------------------------*\
  227.  * void plsmaj()
  228.  *
  229.  * Set up lengths of major tick marks.
  230. \*----------------------------------------------------------------------*/
  231.  
  232. void
  233. c_plsmaj(PLFLT def, PLFLT scale)
  234. {
  235.     if (def != 0.0) 
  236.     plsc->majdef = def;
  237.  
  238.     plsc->majht = scale * plsc->majdef;
  239. }
  240.  
  241. /*----------------------------------------------------------------------*\
  242.  * void plssym()
  243.  *
  244.  * Set symbol height.
  245. \*----------------------------------------------------------------------*/
  246.  
  247. void
  248. c_plssym(PLFLT def, PLFLT scale)
  249. {
  250.     if (def != 0.0) 
  251.     plsc->symdef = def;
  252.  
  253.     plsc->symht = scale * plsc->symdef;
  254. }
  255.  
  256. /*----------------------------------------------------------------------*\
  257.  * void pllsty()
  258.  *
  259.  * Set line style.
  260. \*----------------------------------------------------------------------*/
  261.  
  262. void
  263. c_pllsty(PLINT lin)
  264. {
  265.     if (plsc->level < 1) {
  266.     plabort("pllsty: Please call plinit first");
  267.     return;
  268.     }
  269.     if (lin < 1 || lin > 8) {
  270.     plabort("pllsty: Invalid line style");
  271.     return;
  272.     }
  273.  
  274.     plstyl(line[lin - 1].nels,
  275.        &line[lin - 1].mark[0], &line[lin - 1].space[0]);
  276. }
  277.  
  278. /*----------------------------------------------------------------------*\
  279.  * void plpat()
  280.  *
  281.  * Set fill pattern directly.
  282. \*----------------------------------------------------------------------*/
  283.  
  284. void
  285. c_plpat(PLINT nlin, PLINT *inc, PLINT *del)
  286. {
  287.     PLINT i;
  288.  
  289.     if (plsc->level < 1) {
  290.     plabort("plpat: Please call plinit first");
  291.     return;
  292.     }
  293.     if (nlin < 1 || nlin > 2) {
  294.     plabort("plpat: Only 1 or 2 line styles allowed");
  295.     return;
  296.     }
  297.     for (i = 0; i < nlin; i++) {
  298.     if (del[i] < 0) {
  299.         plabort("plpat: Line spacing must be greater than 0");
  300.         return;
  301.     }
  302.     }
  303.     spat(inc, del, nlin);
  304. }
  305.  
  306. /*----------------------------------------------------------------------*\
  307.  * void plpsty()
  308.  *
  309.  * Set fill pattern, using one of the predefined patterns.
  310.  * A fill pattern <= 0 indicates hardware fill.
  311. \*----------------------------------------------------------------------*/
  312.  
  313. void
  314. c_plpsty(PLINT patt)
  315. {
  316.     if (plsc->level < 1) {
  317.     plabort("plpsty: Please call plinit first");
  318.     return;
  319.     }
  320.     if (patt > 8) {
  321.     plabort("plpsty: Invalid pattern");
  322.     return;
  323.     }
  324.     if (patt != plsc->patt) {
  325.     plsc->patt = patt;
  326.  
  327.     if (plsc->level > 0) {
  328.         plP_state(PLSTATE_FILL);
  329.     }
  330.     }
  331.     if (patt > 0) {
  332.     spat(&pattern[patt - 1].inc[0], &pattern[patt - 1].del[0],
  333.          pattern[patt - 1].nlines);
  334.     }
  335. }
  336.  
  337. /*----------------------------------------------------------------------*\
  338.  * void spat()
  339.  *
  340.  * Set defining parameters for pattern fill 
  341. \*----------------------------------------------------------------------*/
  342.  
  343. static void
  344. spat(PLINT inc[], PLINT del[], PLINT nlin)
  345. {
  346.     PLINT i;
  347.  
  348.     plsc->nps = nlin;
  349.     for (i = 0; i < nlin; i++) {
  350.     plsc->inclin[i] = inc[i];
  351.     plsc->delta[i] = del[i];
  352.     }
  353. }
  354.